package cn.linjianhui.cluster.dao;

import cn.linjianhui.cluster.pojo.UserRedPacket;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRedPacketDao {

    @Insert("insert into t_user_red_packet(red_packet_id, user_id, amount, grab_time, note)" +
            " values(#{packet.redPacketId}, #{packet.userId}, #{packet.amount}, #{packet.grabTime}, '')")
    @Options(useGeneratedKeys=true, keyProperty="id")
    int grabRedPacket(@Param("packet") UserRedPacket packet);

    @InsertProvider(type = UserRedPacketSqlProvider.class, method = "insertUpdateBatch")
    int batchInsertUserRedPacket(@Param("packetList") List<UserRedPacket> packetList);
}
